package com.shouer.doc.ui.healthreportedit.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.shouer.doc.R;
import com.shouer.doc.ui.neworder.model.UserRemark;

import java.util.List;

/**
 * Created by YYY-Work on 2017/8/7.
 */

public class UserRemarkAdapter extends RecyclerView.Adapter<UserRemarkVH> {

    private List<UserRemark> userRemarks;
    private LayoutInflater layoutInflater;

    public UserRemarkAdapter(Context context, List<UserRemark> userRemarks) {
        this.userRemarks = userRemarks;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public UserRemarkVH onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.activity_health_report_edit_question, null);
        return new UserRemarkVH(itemView);
    }

    @Override
    public void onBindViewHolder(UserRemarkVH holder, int position) {

        UserRemark userRemark=userRemarks.get(position);
        holder.question.setText(TextUtils.isEmpty(userRemark.getQuestion())?"":userRemark.getQuestion());
        holder.answer.setText(TextUtils.isEmpty(userRemark.getAnswer())?"":userRemark.getAnswer());

    }

    @Override
    public int getItemCount() {
        if (null == userRemarks)
            return 0;
        else
            return userRemarks.size();
    }

    @Override
    public long getItemId(int position)
    {
        return position;
    }
}
